#ifndef CURRENTTHREAD_H
#define CURRENTTHREAD_H

#include <pthread.h>
#include <unistd.h>
#include <sys/syscall.h>

namespace CurrentThread {
    extern __thread pid_t t_cachedTid;

    inline pid_t getRealTid() {
        if (t_cachedTid == 0) {
            t_cachedTid = syscall(SYS_gettid);
        }
        return t_cachedTid;
    }
}

#endif